#pragma once

#include "skinscrollwnd.h"

// Helper Routine
extern void GradientFillRect( CDC *pDC, CRect &rect, COLORREF col_from, COLORREF col_to, bool vert_grad );


class CVividTree : public CTreeCtrl
{
	DECLARE_DYNAMIC(CVividTree)

public:
	CVividTree();
	virtual ~CVividTree();

// Attributes
	enum BkMode 
	{ 
		BK_MODE_BMP = 0, 
		BK_MODE_GRADIENT, 
		BK_MODE_FILL 
	};

	void SetBitMaps(HBITMAP treeClosed, HBITMAP treeOpen, HBITMAP backGround);

	void SetBkGradients( COLORREF from, COLORREF to )
	{	
		m_gradient_bkgd_from = from; 
	    m_gradient_bkgd_to = to; 
	}

	COLORREF GetBkGradientFrom( )
	{	
		return m_gradient_bkgd_from; 
	}

	COLORREF GetBkGradientTo( )
	{ 
		return m_gradient_bkgd_to; 
	}

	BkMode GetBkMode( ) 
	{ 
		return m_bkgd_mode; 
	}

	void SetBkMode( BkMode bkgd_mode ) 
	{ 
		m_bkgd_mode = bkgd_mode; 
	}

	bool GetBitmapTiledMode() 
	{ 
		return m_bmp_tiled_mode;
	}

	void SetBitmapTiledMode( bool tiled ) 
	{	
		m_bmp_tiled_mode = tiled; 
	}

	bool GetGradientHorz() 
	{ 
		return m_gradient_horz; 
	}

	void SetGradientHorz( bool horz ) 
	{ 
		m_gradient_horz = horz; 
	} 

	virtual void  SetItemIcon(HICON hIcon)			// Overridable
	{ 
		m_icon =  hIcon;
	}; 

	virtual HICON GetItemIcon( HTREEITEM item );	// Overridable

	void SetTextColor(COLORREF c) { m_cTextColor = c;}


// Operations
	bool ItemIsVisible( HTREEITEM item );

private:
	COLORREF m_gradient_bkgd_from;		// Gradient variables
	COLORREF m_gradient_bkgd_to;
	COLORREF m_gradient_bkgd_sel;
	COLORREF m_cTextColor;				//
	bool     m_gradient_horz;			// horz or vertical gradient

	BkMode  m_bkgd_mode;				// Current Background mode
    CBitmap m_bmp_back_ground;			// Background bitmap image
	CBitmap m_bmp_tree_closed;			// Tree open image (marker)
	CBitmap m_bmp_tree_open;			// Tree closed image (marker)
	bool    m_bmp_tiled_mode;			// Tile background image

	CRect m_rect;						// The client rect when drawing
	int   m_h_offset;					// 0... -x (scroll offset)
	int   m_h_size;						// width of unclipped window
	int   m_v_offset;					// 0... -y (scroll offset)
	int   m_v_size;						// height of unclipped window

	HICON m_icon;

	void DrawBackGround( CDC* pDC );	// Background Paint code
	void DrawItems( CDC* pDC );			// Item Paint Code

protected:
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg void OnPaint();
	afx_msg void OnTvnItemexpanding(NMHDR *pNMHDR, LRESULT *pResult);
	DECLARE_MESSAGE_MAP()
};


